/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage.packet.server;

import java.io.IOException;

import lineage.config.L1Config;
import lineage.core.Opcodes;
import lineage.packet.L1AbstractPacketServer;

/**
 * 处理服务端封包：验证版本.
 * 
 * @version 2014年3月11日上午8:40:10
 * @author jrwz
 */
public final class S_ServerVersion extends L1AbstractPacketServer {
    private static final int CLIENT_LANGUAGE = L1Config.CLIENT_LANGUAGE;
    private static final int SERVER_VERSION = 11122715;
    private static final int CACHE_VERSION = 11122064;
    private static final int AUTH_VERSION = 2010083002;
    private static final int NPC_VERSION = 11091501;
    private static final int UP_TIME = 1327204035;
    private byte[] _byte = null;

    /**
     * 处理服务端封包：验证版本.
     */
    public S_ServerVersion() {
        writeC(Opcodes.S_OPCODE_SERVER_VERSION); // 封包码

        writeC(0x00);
        writeC(0x0d);

        writeD(SERVER_VERSION); // server verion
        writeD(CACHE_VERSION); // cache verion
        writeD(AUTH_VERSION); // auth verion
        writeD(NPC_VERSION); // npc verion
        writeD(UP_TIME); // time

        this.writeC(0x00);
        this.writeC(0x00);
        this.writeC(CLIENT_LANGUAGE);
        this.writeC(0x00);
        this.writeC(0x00);
        this.writeC(0x00);
        this.writeC(0x00);
        this.writeC(0x08);
        this.writeC(0x00);
    }

    @Override
    public byte[] getContent() throws IOException {
        if (this._byte == null) {
            this._byte = this.getBytes();
        }
        return this._byte;
    }
}
